import {
  reqToken
} from '../../api/index'
Page({
  data: {

  },
  onLoad(options) {

  },
  //点击授权登录按钮获取code
  getUserProfile() {
    //登录API获取code
    wx.login({
      success: (res) => {
        this.getToken(res.code);
      }
    })
  },
  //获取token
  async getToken(code) {
    //获取用户身份标识token
    let result = await reqToken(code);
    if (result.code == 200) {
      //本地存储持久化存储用户信息
      wx.setStorageSync("TOKEN", result.data.token);
      wx.navigateTo({
        url: '/pages/edit/edit',
      })
    }

  }
})